package com.example.points.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.points.domain.UserPoints;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface UserPointsMapper extends BaseMapper<UserPoints> {
    @Update("UPDATE user_points SET available_points = available_points + #{points}, " +
            "total_points = total_points + #{points}, version = version + 1 " +
            "WHERE user_id = #{userId} AND version = #{version}")
    int updatePoints(@Param("userId") Long userId, @Param("points") Long points, @Param("version") Integer version);
} 